﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ActivitiesControl.GUI.Desktop.Forms
{
	public partial class ActivitiesControlMonthReportForm : Form
	{
		public ActivitiesControlMonthReportForm()
		{
			InitializeComponent();

			BindFilterComboCustomers();
			
			numberYear.Value = DateTime.Now.Year;
			numberMonth.Value = DateTime.Now.AddMonths(-1).Month;

			GenerateReport();
		}

		private void btnReport_Click(object sender, EventArgs e)
		{
			GenerateReport();
		}

		private void GenerateReport()
		{
			this.activitiesControlTableAdapter.Fill(
				this.activitiesControlDataSet.ActivitiesControl, 
				numberYear.Value, 
				numberMonth.Value, 
				Convert.ToInt32(comboFilterCustomers.SelectedValue));

			this.reportViewer1.RefreshReport();
		}

		private void BindFilterComboCustomers()
		{
			comboFilterCustomers.DataSource = ServicesLocator.CustomerServices.GetCustomersForFilter().ToList();
			comboFilterCustomers.SelectedIndex = 0;
		}
	}
}
